<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>ioko-tapestry-commons - </title>
    <style type="text/css" media="all">
      @import url("./css/maven-base.css");
      @import url("./css/maven-theme.css");
      @import url("./css/site.css");
    </style>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
                                                    
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
                                                        
<script type="text/javascript">try {
                var pageTracker = _gat._getTracker("UA-75598-9");
                pageTracker._trackPageview();
                } catch(err) {}</script>
                    </head>
  <body class="composite">
    <div id="banner">
                  <a href="http://tapestry.formos.com/projects/ioko-tapestry-commons/" id="bannerLeft">
    
                                            <img src="images/tapestry-commons.png" alt="" />
    
            </a>
                        <a href="http://www.ioko.com/" id="bannerRight">
    
                                            <img src="images/ioko.png" alt="" />
    
            </a>
            <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
            
  
    
            <div class="xleft">
        Last Published: 2009-09-24
                      </div>
            <div class="xright">      
  

  
    
            
  
    
             Version: 1.6.0-SNAPSHOT
      </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
            
  
    
                   <h5>Sites</h5>
            <ul>
              
    <li class="none">
                    <a href="http://tapestry.formos.com/projects/ioko-tapestry-commons/" class="externalLink">Release Site</a>
          </li>
              
    <li class="none">
                    <a href="http://tapestry.formos.com/nightly/ioko-tapestry-commons/" class="externalLink">Nightly Site</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
              
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
              
        <li class="collapsed">
                    <a href="project-info.html">Project Information</a>
                </li>
          </ul>
                        <h5>Developers</h5>
            <ul>
              
    <li class="none">
                    <a href="development.html">Development Guide</a>
          </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
            
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>Cache Control</h2>
<p>This module add the ability to control the caching of your tapestry pages by simply annotating the page class.</p>
<div class="source"><pre>  @CacheControl(cacheType = CacheType.NEVER)
  public class myPage(){

    ....

  }
</pre>
</div>
</div>
<div class="section"><h2>Cache Type</h2>
<p>This library supports the following cachetypes</p>
<ul><li>NEVER - Never cache the page</li>
<li>SHORT - A short time (default 5 minutes)</li>
<li>MEDIUM - A medium time (default 1 hour)</li>
<li>LONG - A long time (default 1 day)</li>
<li>FAR_FUTURE - Cache the page for a extremely long time (default 10 years)</li>
<li>NONE - Don't do anything to this page<p>The cache types are configured via application defaults so you can override them by contributing your own preferences. The time parameter is in seconds.</p>
<div class="source"><pre> public static void contributeApplicationDefaults(MappedConfiguration&lt;String,String&gt; configuration)
  {
    configuration.add(cacheControl.short, &quot;60&quot;);
    configuration.add(cacheControl.medium, &quot;600&quot;);
    configuration.add(cacheControl.long, &quot;6000&quot;);
    configuration.add(cacheControl.farFuture, &quot;60000&quot;);
  }</pre>
</div>
</li>
</ul>
</div>
<div class="section"><h2>Default Cache Type</h2>
<p>The library also has a default cache header applied to all pages. This default is set (by default) to NEVER. This can also be changed by contributing a default</p>
<div class="source"><pre>     configuration.add(CacheControlTransformer.CACHE_TYPE_METADATA, CacheType.NONE);</pre>
</div>
</div>
<div class="section"><h2>AJAX Event Caching</h2>
<p>It is possible to set and use cache control headers on AJAX events. This can be very handy as they can cause substantial load. However this also comes with a health warning - you need to think carefully before enabling this as if you do it wrong you could share data between users!</p>
<p>You need to enable this by add the following application default</p>
<div class="source"><pre>        configuration.add(&quot;cacheControl.enableEventHeaders&quot;, String.valueOf(true));</pre>
</div>
<p>This will enable setting cache control headers for AJAX events. This will change all tapestry AJAX events to use a GET instead of a post.</p>
<p>The headers set will be</p>
<ul><li>By Default the system wide default (which is no headers unless you change it)</li>
<li>If the page has an annotation is will set those</li>
<li>If the event needs to overide the page annotation you can inject CacheControlSupport and set the desired header<div class="source"><pre>    public Block onActionFromNoneAjax() {

                cacheControlSupport.setCacheType(CacheType.NONE);
                return ajaxResponse;
        }</pre>
</div>
</li>
</ul>
</div>
<div class="section"><h2>Implementation Notes</h2>
<div class="section"><h3>Headers</h3>
<p>The library seeks to use headers that will work with many proxy servers/browsers so it sets</p>
<ul><li>Expires</li>
<li>Cache Control</li>
<li>Pragma='no-cache'</li>
</ul>
</div>
<div class="section"><h3>Ajax Event</h3>
<p>The ajax event implementation overides the ajaxRequest function is tapestry.js to change the default method to GET (as opposed to POST). This is a global setting so once enabled will impact ALL ajax requests.</p>
<p>This is done as part of page initialisation - it is not therefore guarenteed if you called Tapestry.ajaxRequest in an included JS file it will run after (or before) this overide occurs. In reality this is unlikely to be an issue as AJAX doesn't generally occur on page load - and if you wanted to do that putting your call in an init function should solve the issue.</p>
<p>One side effect of changing from POST to GET is all AJAX requests will need cache headers to stop them being cached. Therefore is you enable AJAX caching you should change the default cacheType to be NEVER in your application defaults</p>
<div class="source"><pre>      configuration.add(CacheControlTransformer.CACHE_TYPE_METADATA, CacheType.NEVER);</pre>
</div>
</div>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2009
    
          ioko
          
  

  
    
            
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
